import service from "./service";
import { config } from "./config";

const { default_headers } = config;
const request = (option: any) => {
  const { url, method, params, data, headersType, responseType, ...config } = option;

  return service({
    url,
    method,
    params,
    data,
    ...config,
    responseType,
    headers: {
      "Content-Type": headersType || default_headers,
    },
  });
};
export default {
  get: async (option: any) => {
    const res = await request({
      method: "GET",
      ...option,
    });
    return res;
  },
  post: async (option: any) => {
    const res = await request({
      method: "POST",
      ...option,
    });
    return res;
  },
};
